<script setup>
import { computed } from "vue";
import { useStore } from "vuex";
const store = useStore();
const list = computed(() => store.state.list);

const handleResult = () => {
  store.commit("setState", { pageIndex: -2 });
};
const handleClick = (index) => {
  store.commit("setState", { pageIndex: index });
};
</script>

<template>
  <div class="box">
    <div class="title">文案目录</div>
    <div class="scroll-view">
      <div class="emtpy" v-if="!list.length">数据列表是空的</div>
      <div class="btn-list">
        <div
          class="item"
          v-for="(item, index) in list"
          :key="index"
          @click="handleClick(index)"
        >
          <div class="icon">
            <img src="@/assets/star.png" alt="" />
          </div>
          <div class="text">{{ item.title }}</div>
          <div class="tip" v-if="item.mading">(制作ing)</div>
        </div>
      </div>
    </div>
    <div class="foot">
      <div class="btn-res" @click="handleResult">声鉴结果</div>
    </div>
  </div>
</template>

<style scoped lang='scss'>
.box {
  background-color: #fff;
  color: #000;
  width: 266px;
  height: 355px;
  box-sizing: border-box;
  margin: 10px auto 0;
  position: relative;
  .title {
    text-align: center;
    font-size: 24px;
    height: 42px;
    line-height: 42px;
    font-weight: bold;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    box-shadow: 0px -7px 20px 1px rgba(0, 0, 0, 0.1);
  }
  .scroll-view {
    position: absolute;
    top: 42px;
    bottom: 42px;
    left: 0;
    right: 0;
    width: 100%;
    height: calc(100% - 84px);
    overflow-y: scroll;
    overflow-x: hidden;
    &::-webkit-scrollbar {
      width: 4px;
      background-color: transparent;
    }
    &::-webkit-scrollbar-thumb {
      width: 4px;
      background-color: #c8efd4;
      border-radius: 2px;
    }
    .btn-list {
      display: flex;
      flex-wrap: wrap;
      margin-top: 24px;
      padding: 0 20px;
      .item {
        width: 50%;
        height: 40px;
        display: flex;
        justify-content: center;
        align-items: center;
        position: relative;
        &:hover {
          .icon {
            opacity: 1;
          }
          .text {
            color: plum;
          }
        }
        .icon {
          width: 28px;
          height: 28px;
          display: flex;
          justify-content: center;
          align-items: center;
          cursor: pointer;
          margin-right: 4px;
          opacity: 0.7;
          img {
            display: block;
            width: 100%;
          }
        }
        .text {
          width: 4em;
          font-size: 18px;
          cursor: pointer;
          white-space: nowrap;
          color: #000;
        }
        .tip {
          position: absolute;
          bottom: -2px;
          right: 10px;
          font-size: 14px;
        }
      }
    }
  }
  .foot {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 42px;
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    .btn-res {
      padding: 0 10px;
      width: max-content;
      height: 24px;
      display: flex;
      justify-content: center;
      align-items: center;
      cursor: pointer;
      &:hover {
        color: plum;
      }
    }
  }
}
</style>
